home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / timer / impl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-25  |  1.7 KB  |  74 lines

  1. /*
  2.  * (c) Copyright 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef IMPL_H
  8. #define IMPL_H
  9.  
  10. /*
  11.  * $Id: impl.h,v 4.2 1993/05/06 06:47:03 panos Exp $
  12.  */
  13.  
  14. #include <sys/time.h>
  15. #include <setjmp.h>
  16.  
  17. #include "pq.h"
  18. #include "timer.h"
  19. #include "ostimer.h"
  20.  
  21. enum timer_state { INACTIVE, TICKING, DESTROYED } ;  
  22. enum action_state { IDLE, PENDING, SCHEDULED, INVOKED } ;
  23.  
  24.  
  25. struct timer
  26. {
  27.     enum timer_state         t_state ;
  28.     enum action_state     t_act ;
  29.     int                        t_blocked ;
  30.  
  31.     int                         t_flags ;
  32.     int                        *t_errnop ;
  33.     struct os_timer        *t_ostimer ;
  34.     struct timer_action    t_action ;
  35.  
  36.     /*
  37.      * The following fields are managed by the ostimer code.
  38.      * t_expiration is the (absolute) time when the timer will expire.
  39.      * t_interval is the repeat interval for the timer.
  40.      * t_expirations is the number of expirations of the timer when
  41.      * the function associated with the timer is invoked.
  42.      * t_count is the number of times that the timer has expired before
  43.      * the function was invoked.
  44.      */
  45.     struct timeval            t_expiration ;
  46.     struct timeval            t_interval ;
  47.     unsigned                    t_count ;
  48.     unsigned                    t_expirations ;
  49. } ;
  50.  
  51. typedef struct timer timer_s ;
  52.  
  53. #define TP( p )                ( (struct timer *) (p) )
  54.  
  55. char *malloc() ;
  56.  
  57. #define TIMER_ALLOC()        TP( malloc( sizeof( timer_s ) ) )
  58. #define TIMER_FREE( tp )    (void) free( (char *)(tp) )
  59.  
  60. /*
  61.  * The following are masks for the expected flags of timer_create and
  62.  * timer_start
  63.  */
  64. #define TIMER_CREATE_FLAGS        TIMER_RETURN_ERROR
  65. #define TIMER_START_FLAGS        \
  66.             ( TIMER_INC_VAR + TIMER_BLOCK_SAME + TIMER_BLOCK_ALL + TIMER_LONGJMP )
  67.  
  68.  
  69. enum timer_state __timer_invoke() ;
  70. void __timer_terminate() ;
  71.  
  72. #endif    /* IMPL_H */
  73.  
  74.